
$(function(){
	page.bind();
	page.getAllSearchWhere();
});
var table;
var page = { 
		pageSearchWhereArray:[],//物料筛选条件数组（物料信息） 
		pageIdArray:['providerName','materialName','model','color'],
		getAllSearchWhere:function(){/**获取所有筛选条件*/ 
			ajaxRequest("materialSelectFilter/getMaterialSelectData",{"type":"5","isValid":1}).then(function(res){
				page.pageSearchWhereArray=res; 
				filterInput.filterView("",page.pageIdArray,page.pageSearchWhereArray);
			}).catch(function(error){
				console.log(error);
			});  
		},
		getSendParam:function(){
			/**
			 * 配置要素绑定
			 */
			for(var i=0;i<page.pageIdArray.length;i++){
				$("#"+page.pageIdArray[i]).bind("change",function(){
					filterInput.filterView("",page.pageIdArray,page.pageSearchWhereArray);
				});
			}
			var object=new Object();
			object.materialName=$("#materialName").val();
			object.model=$("#model").val();
			object.providerName=$("#providerName").val();
			var color=$("#color").val();
			if(color.trim()!==""){
				object.color = color; 
			} 
			//不查出库存为0的 李斌
			object.isValid = 1; 
			return object;
		},
		bind:function(){
			$("#queryBtn").bind("click",function(){
				var object = page.getSendParam();
				page.getMaterial(object);
				page.getMaterialSumPirce(object);
			});
		},
		getMaterial:function(object){
			table=ajaxUtil.dataTablesAjax("materialTable",10,"companyMaterial/getCompanyMaterialByMapToPage",
					object,[
					{"data":"materialName"},
					{"data":"model"},
					{"data":"providerName"},
					{"data":"color"},
					{"data":"colorDescription"},
					{"data":"defaultWarehouse"},
					{"data":"unitPrice"},
					{"data":"count"},
					{"data":"sumPrice"}
			]); 
		},
		getMaterialSumPirce:function(object){
			ajaxUtil.ajaxRuquest("companyMaterial/getCompanyMaterialByMapToPageSumPrice",object,function(data){
				$("#sumPrice").text("总价："+data);
			});
		}
}